#include "PokemonAttack.h"

using namespace std;

PokemonAttack::PokemonAttack(const AttackData& _data)
	: m_IsCritical(false), m_IsSuperEffective(false), m_IsNotVeryEffective(false), m_HasMissed(false)
{
	m_AttackData.number = _data.number;
	m_AttackData.name = _data.name;
	m_AttackData.type = _data.type;
	m_AttackData.pp = _data.pp;
	m_AttackData.power = _data.power;
	m_AttackData.accuracy = _data.accuracy;
	m_AttackData.targetOther = _data.targetOther;
	m_AttackData.status = _data.status;
	m_AttackData.statusValue = _data.statusValue;
	m_AttackData.animation = _data.animation;

	ResetCurrentPP();
}

PokemonAttack::PokemonAttack(const PokemonAttack& _source)
{
	m_AttackData.number = _source.m_AttackData.number;
	m_AttackData.name = _source.m_AttackData.name;
	m_AttackData.type = _source.m_AttackData.type;
	m_AttackData.pp = _source.m_AttackData.pp;
	m_AttackData.power = _source.m_AttackData.power;
	m_AttackData.accuracy = _source.m_AttackData.accuracy;
	m_AttackData.targetOther = _source.m_AttackData.targetOther;
	m_AttackData.status = _source.m_AttackData.status;
	m_AttackData.statusValue = _source.m_AttackData.statusValue;
	m_AttackData.animation = _source.m_AttackData.animation;

	m_IsCritical = _source.m_IsCritical;
	m_IsSuperEffective = _source.m_IsSuperEffective;
	m_IsNotVeryEffective = _source. m_IsNotVeryEffective;
	m_HasMissed = _source.m_HasMissed;

	m_CurrentPP = _source.GetCurrentPP();
}

PokemonAttack& PokemonAttack::operator=(const PokemonAttack& _source)
{
	m_AttackData.number = _source.m_AttackData.number;
	m_AttackData.name = _source.m_AttackData.name;
	m_AttackData.type = _source.m_AttackData.type;
	m_AttackData.pp = _source.m_AttackData.pp;
	m_AttackData.power = _source.m_AttackData.power;
	m_AttackData.accuracy = _source.m_AttackData.accuracy;
	m_AttackData.targetOther = _source.m_AttackData.targetOther;
	m_AttackData.status = _source.m_AttackData.status;
	m_AttackData.statusValue = _source.m_AttackData.statusValue;
	m_AttackData.animation = _source.m_AttackData.animation;
	
	m_IsCritical = _source.m_IsCritical;
	m_IsSuperEffective = _source.m_IsSuperEffective;
	m_IsNotVeryEffective = _source. m_IsNotVeryEffective;
	m_HasMissed = _source.m_HasMissed;

	m_CurrentPP = _source.GetCurrentPP();

	return *this;
}

ostream& operator<<(ostream& _out, const PokemonAttack& _source)
{
	_out << _source.GetAttackData().name;

	return _out;
}

PokemonAttack::~PokemonAttack()
{

}

bool PokemonAttack::IsPhysical() const
{
	switch(m_AttackData.type)
	{
	case WATER:
	case GRASS:
	case FIRE:
	case ICE:
	case ELECTRIC:
	case PSYCHIC:
	case DRAGON:
		return false;
		break;
	default:
		return true;
		break;
	}
}

void PokemonAttack::InitAttack()
{
	ResetCurrentPP();
	InitAttackStatus();
}

void PokemonAttack::InitAttackStatus()
{
	m_IsCritical = false;
	m_IsSuperEffective = false;
	m_IsNotVeryEffective = false;
	m_HasMissed = false;
}